package com.asamioffice.goldenport.servlet;

import java.io.IOException;
import java.util.Date;
import java.util.logging.Logger;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

/**
 * @since   Oct.  2, 2010
 * @version Oct.  2, 2010
 * @author  ASAMI, Tomoharu
 */
public class PerfFilter implements Filter {
    private static final Logger logger = Logger.getLogger(PerfFilter.class.getName());

    public void init(FilterConfig arg) throws ServletException {
    }

    public void destroy() {
    }

    public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)
            throws IOException, ServletException {

        Date startDateTime = new Date();
        logger.finer("ENTER[" + startDateTime + "]");
        chain.doFilter(req, res);        
        Date endDateTime = new Date();
        long ellapse = endDateTime.getTime() - startDateTime.getTime();
        logger.finer("LEAVE[" + ellapse + "]");
    }
}

